﻿<UserControl x:Class="AnalysisTesteur.Views.ItemDataConfigControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit" 
             xmlns:Models="clr-namespace:AnalysisTesteur.Models"
             xmlns:ModelImpls="clr-namespace:AnalysisTesteur.Models.DashboardItemImpls"
            xmlns:ig="http://schemas.infragistics.com/xaml"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.DataContext>
        <ModelImpls:DashboardDataItem />
    </UserControl.DataContext>
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        
        <Style TargetType="ListBoxItem" x:Key="BaseListBoxitemStyle">
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="Margin" Value="2" />
            <Setter Property="Padding" Value="5" />
            <Setter Property="BorderThickness" Value="2" />
            <Setter Property="BorderBrush" Value="Black" />
           
        </Style>
        <DataTemplate x:Key="BaseListBoxitemTemplate" DataType="{x:Type Models:DashboardItemDimension}">
            <DockPanel>
                <Button Background="{x:Null}" Focusable="False" DockPanel.Dock="Right" BorderBrush="{x:Null}" BorderThickness="0" Command="{Binding Path=DeleteCommand}">
                    <Image Width="16" Height="16" Source="/AnalysisTesteur;component/Resources/Ribbon/Images/remove_32.png" Stretch="Fill" />
                </Button>
                <toolkit:DropDownButton Focusable="False" DockPanel.Dock="Right" BorderBrush="{x:Null}" BorderThickness="0"  Background="{x:Null}">
                    <Image Width="16" Height="16" Source="/AnalysisTesteur;component/Resources/Images/configuration-icon.png" />
                    <toolkit:DropDownButton.DropDownContent>
                        <StackPanel>
                            <MenuItem Header="Tri Croissant">
                                <MenuItem.Icon>
                                    <Image Source="/AnalysisTesteur;component/Resources/Images/SortAscending.png" />
                                </MenuItem.Icon>
                               
                            </MenuItem>
                            <MenuItem Header="Tri Decroissant">
                                <MenuItem.Icon>
                                    <Image Source="/AnalysisTesteur;component/Resources/Images/SortDescending.png" />
                                </MenuItem.Icon>
                               
                            </MenuItem>
                        </StackPanel>
                    </toolkit:DropDownButton.DropDownContent>
                </toolkit:DropDownButton>                
                <TextBlock VerticalAlignment="Center" Text="{Binding SheetItemDimension.Column}" />
            </DockPanel>
        </DataTemplate>
        <DataTemplate x:Key="BaseMeasureListBoxitemTemplate" DataType="{x:Type Models:DashboardItemMeasure}">
            <DockPanel>
                <Button Background="{x:Null}" Focusable="False" DockPanel.Dock="Right" BorderBrush="{x:Null}" BorderThickness="0" Command="{Binding Path=DeleteCommand}">
                    <Image Width="16" Height="16" Source="/AnalysisTesteur;component/Resources/Ribbon/Images/remove_32.png" Stretch="Fill" />
                </Button>
                <toolkit:DropDownButton Focusable="False" DockPanel.Dock="Right" BorderBrush="{x:Null}" BorderThickness="0"  Background="{x:Null}">
                    <Image Width="16" Height="16" Source="/AnalysisTesteur;component/Resources/Images/configuration-icon.png" />
                    <toolkit:DropDownButton.DropDownContent>
                        <StackPanel>
                            <MenuItem Command="{Binding Path=ChangeAggregateCommand}" CommandParameter="Count" Header="Count" />
                            <MenuItem Command="{Binding Path=ChangeAggregateCommand}" CommandParameter="CountRows" Header="CountRows" />
                            <MenuItem Command="{Binding Path=ChangeAggregateCommand}" CommandParameter="CountNull" Header="CountNull" />
                            <MenuItem Command="{Binding Path=ChangeAggregateCommand}" CommandParameter="Min" Header="Min" />
                            <MenuItem Command="{Binding Path=ChangeAggregateCommand}" CommandParameter="Max" Header="Max" />
                            <MenuItem Command="{Binding Path=ChangeAggregateCommand}" CommandParameter="Range" Header="Range" />
                            <MenuItem Command="{Binding Path=ChangeAggregateCommand}" CommandParameter="First" Header="First" />
                            <MenuItem Command="{Binding Path=ChangeAggregateCommand}" CommandParameter="Last" Header="Last" />
                            <MenuItem Command="{Binding Path=ChangeAggregateCommand}" CommandParameter="Avg" Header="Avg" />
                            <MenuItem Command="{Binding Path=ChangeAggregateCommand}" CommandParameter="Sum" Header="Sum" />
                            <MenuItem Command="{Binding Path=ChangeAggregateCommand}" CommandParameter="Std" Header="Std" />
                            <MenuItem Command="{Binding Path=ChangeAggregateCommand}" CommandParameter="Var" Header="Var" />
                            <MenuItem Command="{Binding Path=ChangeAggregateCommand}" CommandParameter="CV" Header="CV" />
                        </StackPanel>
                    </toolkit:DropDownButton.DropDownContent>
                </toolkit:DropDownButton>
                <TextBlock VerticalAlignment="Center" >
                    <TextBlock.Inlines>
                        <Run Text="{Binding Path=MeasureAggregate, Mode=OneWay}" FontWeight="Bold" Foreground="Red" />
                        <Run Text="(" />
                        <Run FontStyle="Italic" Text="{Binding Path=SheetItemMeasure.ValueColumn, Mode=OneWay}" Foreground="Green" FontWeight="Bold"  />
                        <Run Text=")" />
                    </TextBlock.Inlines>
                </TextBlock>
            </DockPanel>
        </DataTemplate>
        <Style TargetType="ListBox" x:Key="EditListBoxStyle">
            <Setter Property="BorderBrush" Value="{x:Null}" />
            <Setter Property="BorderThickness" Value="0" />
        </Style>
    </UserControl.Resources>
    
    <Grid>
        <UniformGrid Rows="{Binding Path=AcceptCount, FallbackValue=4}" Columns="1">

            <GroupBox Header="Lignes" Margin="5" Visibility="{Binding Path=AcceptRow, Converter={StaticResource BooleanToVisibilityConverter}}">

                <ListBox 
                    Drop="ListBox_Drop" Name="RowListbox"  AllowDrop="True" 
                    ItemsSource="{Binding Path=RowDimensionList}" DataContext="{Binding}" 
                    Style="{StaticResource EditListBoxStyle}" 
                    ItemTemplate="{StaticResource BaseListBoxitemTemplate}" >
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem" BasedOn="{StaticResource BaseListBoxitemStyle}">
                          
                        </Style>
                    </ListBox.ItemContainerStyle>
                   
                </ListBox>
            </GroupBox>

            <GroupBox Header="Colonnes"  Margin="5" Visibility="{Binding Path=AcceptColumn, Converter={StaticResource BooleanToVisibilityConverter}}">
                <ListBox  DataContext="{Binding}" Name="ColumnListbox" 
                          AllowDrop="True" Drop="ListBox_Drop" 
                          ItemsSource="{Binding Path=ColumnDimensionList}" 
                          Style="{StaticResource EditListBoxStyle}"
                          ItemTemplate="{StaticResource BaseListBoxitemTemplate}">
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem" BasedOn="{StaticResource BaseListBoxitemStyle}">

                        </Style>
                    </ListBox.ItemContainerStyle>
                </ListBox>
            </GroupBox>

            <GroupBox Header="Series"  Margin="5"  Visibility="{Binding Path=AcceptSerie, Converter={StaticResource BooleanToVisibilityConverter}}">
                <ListBox Name="SerieListbox" DisplayMemberPath="ColumnData.Name" AllowDrop="True" Drop="ListBox_Drop"  ItemsSource="{Binding Path=SerieDimensionList}" Style="{StaticResource EditListBoxStyle}">
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem" BasedOn="{StaticResource BaseListBoxitemStyle}">

                        </Style>
                    </ListBox.ItemContainerStyle>
                </ListBox>
            </GroupBox>

            <GroupBox Header="Données"  Margin="5"  Visibility="{Binding Path=AcceptMeasure, Converter={StaticResource BooleanToVisibilityConverter}}">
                <ListBox Name="MeasureListbox"  AllowDrop="True" Drop="ListBox_Drop"  ItemsSource="{Binding Path=MeasureList}" Style="{StaticResource EditListBoxStyle}" ItemTemplate="{StaticResource BaseMeasureListBoxitemTemplate}">
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem" BasedOn="{StaticResource BaseListBoxitemStyle}">

                        </Style>
                    </ListBox.ItemContainerStyle>
                </ListBox>
            </GroupBox>
        </UniformGrid>
    </Grid>
</UserControl>
